{% extends "../base_adminlte.html" %}
{% load custom_markdown %}
{% block content %}
<link rel="stylesheet" href="/static/ansible/css/jsonformat.css">
<div class="content-wrapper">
  <!-- Content Header (Page header) -->
    <div class="content-header">
    </div>
  <section class="content">
	<button onclick="location.reload();">刷新页面</button>

      <table class="table table-bordered">
        <tr style="background-color: #3c8dbc80;"><td>Name</td><td>Content</td></tr>
        <tr>
            <td style="background-color: gainsboro;">AnsibleID</td>
            <td style="background-color: #d0eae9;" id="ansible_id">{{ t.AnsibleID }}</td>
        </tr>
        <tr>
                <td style="background-color: gainsboro;">CeleryID</td>
                <td style="background-color: #d0eae9;">{{ t.CeleryID }}</td>
        </tr>
        <tr>
                <td style="background-color: gainsboro;">TaskName</td>
                <td style="background-color: #d0eae9;">{{ t.TaskName }}</td>
        </tr>
        <tr>
                <td style="background-color: gainsboro;">User</td>
                <td style="background-color: #d0eae9;">{{ t.TaskUser }}</td>
        </tr>
        <tr>
                <td style="background-color: gainsboro;">SystemName</td>
                <td style="background-color: #d0eae9;" id="sysnm">{{ t.SystemName }}</td>
        </tr>
        <tr>
                <td style="background-color: gainsboro;">playbook</td>
                <td style="background-color: #d0eae9;">{{ t.playbook }}</td>
        </tr>
        <tr>
                <td style="background-color: gainsboro;">AnsibleResult<br>
                        <button id="anaload"class="btn btn-default" style="margin-top:50px" {% if not t.AnsibleResult %}disabled{%endif%}>解析入库</button>
                </td>
                <td style="background-color: #d0eae9;" id="arctt" ><pre id='ar' style="background: #a5a3a3;white-space: pre-wrap;">{{ t.AnsibleResult|ansible_result }}</pre></td>
        </tr>
        <tr>
                <td style="background-color: gainsboro;">CeleryResult</td>
                <td  style="background-color: #d0eae9;"><pre id='cr' style="height:auto"></pre>  </td>
        </tr>
        <tr>
                <td style="background-color: gainsboro;">CreateTime</td>
                <td  style="background-color: #d0eae9;">{{ t.CreateTime }}</td>
        </tr>
      </table>
      <div hidden><pre id="ext"></pre></div>
  </section>
</div>

{% endblock %}

{% block scriptcontent %}
<script src="/static/ansible/js/jsonformat.js"></script>
<script type="text/javascript">
  $('#cr')[0].innerHTML = syntaxHighlight({{ t.CeleryResult|safe }})     // 格式化结果
  $('#anaload').click(function(){
      $.ajax({
            url: '/ansible/analysisload/',
            data:{"SystemName":$('#sysnm').text(), "ansibleid":$('#ansible_id').text(), "AnsibleResult":$('#arctt').text()},
            type: 'POST',
            dataType: 'json',
            success: function(data){
               alert('分析入库成功数: '+data);
            },
      });
  })
</script>
{% endblock %}
